//
//  ReportCardTCell.m
//  jzyParents
//
//  Created by 任辰东 on 2022/8/20.
//

#import "ReportCardTCell.h"

@interface ReportCardTCell ()

@property (nonatomic, strong) UIView *containerView;
//@property (nonatomic, strong) UIImageView *icon;
//@property (nonatomic, strong) UILabel *classLabel;

@property (nonatomic, strong) UIImageView *typeIcon;
@property (nonatomic, strong) UILabel *typeLabel;

//@property (nonatomic, strong) UIImageView *kemuIcon;
//@property (nonatomic, strong) UILabel *kemuLabel;

@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UILabel *timeLanel;
@end

@implementation ReportCardTCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)configCellWithModel:(ReportCardModel *)model
{
    if (model.is_liankao.boolValue) {
        self.typeLabel.text = @"联考";
        self.typeIcon.backgroundColor = UIColorFromHex(0xff9900);
    }else{
        self.typeLabel.text = @"校考";
        self.typeIcon.backgroundColor = UIColorFromHex(0x00a0e9);
    }
    
    [self.contentLabel setText:model.name lineSpacing:3];
    self.timeLanel.text = [model.xiangmu_time_start dateStringWithFormat:@"yyyy-MM-dd HH:mm"];
    
}

-(void)setupViews
{
    [self.contentView addSubview:self.containerView];
//    [self.containerView addSubview:self.icon];
//    [self.containerView addSubview:self.classLabel];
    
    [self.containerView addSubview:self.typeIcon];
    [self.containerView addSubview:self.typeLabel];
    
//    [self.containerView addSubview:self.kemuIcon];
//    [self.containerView addSubview:self.kemuLabel];
    
    [self.containerView addSubview:self.contentLabel];
    [self.containerView addSubview:self.timeLanel];

}

-(void)setupLayout
{
    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.equalTo(self.contentView);
    }];
    
//    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.top.equalTo(self.containerView).offset(15);
//        make.left.equalTo(self.containerView).offset(15);
//        make.height.mas_equalTo(20);
////        make.width.mas_equalTo(39);
//    }];
//    
//    [self.classLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//       
////        make.edges.equalTo(self.icon);
//        make.left.equalTo(self.icon).offset(10);
//        make.top.bottom.equalTo(self.icon);
//        make.right.equalTo(self.icon).offset(-3);
//    }];
    
    [self.typeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.containerView).offset(15);
        make.left.equalTo(self.containerView).offset(15);
        make.height.mas_equalTo(20);
//        make.width.mas_equalTo(49);
    }];
    
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
//        make.edges.equalTo(self.icon);
        make.left.equalTo(self.typeIcon).offset(8);
        make.top.bottom.equalTo(self.typeIcon);
        make.right.equalTo(self.typeIcon).offset(-8);
    }];
    
//    [self.kemuIcon mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.top.equalTo(self.containerView).offset(15);
//        make.left.equalTo(self.typeIcon.mas_right).offset(5);
//        make.height.mas_equalTo(20);
////        make.width.mas_equalTo(49);
//    }];
//    
//    [self.kemuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//       
////        make.edges.equalTo(self.icon);
//        make.left.equalTo(self.kemuIcon).offset(8);
//        make.top.bottom.equalTo(self.kemuIcon);
//        make.right.equalTo(self.kemuIcon).offset(-8);
//    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
//        make.top.equalTo(self.containerView).offset(15);
        make.top.equalTo(self.typeIcon.mas_bottom).offset(10);
        make.left.equalTo(self.containerView).offset(15);
        make.right.equalTo(self.containerView).offset(-15);
    }];
    
    [self.timeLanel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.contentLabel.mas_bottom).offset(10);
        make.left.equalTo(self.containerView).offset(15);
        make.right.equalTo(self.containerView).offset(-15);
        make.bottom.equalTo(self.containerView).offset(-15);
    }];

}

#pragma mark -- lazyload

-(UIView *)containerView
{
    if (!_containerView) {
        _containerView = [UIView new];
        _containerView.backgroundColor = UIColorFromHex(kColorWhite);
        [_containerView addBottomLineWithEdge:UIEdgeInsetsMake(0, 15, 0, 15)];
    }
    return _containerView;
}

//-(UIImageView *)icon
//{
//    if (!_icon) {
//        _icon = [[UIImageView alloc]initWithImage:UIImageWithName(@"study_report_cell_icon")];
//    }
//    return _icon;
//}

-(UIImageView *)typeIcon
{
    if (!_typeIcon) {
//        _typeIcon = [[UIImageView alloc]initWithImage:UIImageWithName(@"study_report_cell_icon")];
        _typeIcon = [UIImageView new];
        _typeIcon.layer.cornerRadius = 3;
        _typeIcon.layer.masksToBounds = YES;
    }
    return _typeIcon;
}

//-(UIImageView *)kemuIcon
//{
//    if (!_kemuIcon) {
////        _kemuIcon = [[UIImageView alloc]initWithImage:UIImageWithName(@"study_report_cell_icon")];
//        _kemuIcon = [UIImageView new];
//        _kemuIcon.layer.cornerRadius = 3;
//        _kemuIcon.layer.masksToBounds = YES;
//    }
//    return _kemuIcon;
//}

//-(UILabel *)classLabel
//{
//    if (!_classLabel) {
//        _classLabel = [UILabel new];
//        _classLabel.textColor = UIColorFromHex(kColorWhite);
//        _classLabel.font = UIFontSize(12);
//        _classLabel.textAlignment = NSTextAlignmentCenter;
//    }
//    return _classLabel;
//}

-(UILabel *)typeLabel
{
    if (!_typeLabel) {
        _typeLabel = [UILabel new];
        _typeLabel.textColor = UIColorFromHex(kColorWhite);
        _typeLabel.font = UIFontSize(12);
        _typeLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _typeLabel;
}

//-(UILabel *)kemuLabel
//{
//    if (!_kemuLabel) {
//        _kemuLabel = [UILabel new];
//        _kemuLabel.textColor = UIColorFromHex(kColorWhite);
//        _kemuLabel.font = UIFontSize(12);
//        _kemuLabel.textAlignment = NSTextAlignmentCenter;
//    }
//    return _kemuLabel;
//}

-(UILabel *)contentLabel
{
    if (!_contentLabel) {
        _contentLabel = [UILabel new];
        _contentLabel.textColor = UIColorFromHex(0x000000);
        _contentLabel.font = UIFontSize(16);
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}

-(UILabel *)timeLanel
{
    if (!_timeLanel) {
        _timeLanel = [UILabel new];
        _timeLanel.textColor = UIColorFromHex(kColorSubTitle);
        _timeLanel.font = UIFontSize(15);
    }
    return _timeLanel;
}

@end
